package jianzhi_offer;

import java.util.Stack;

public class _20_栈的压入弹出序列 {
	//用栈辅助
	public boolean IsPopOrder(int [] pushA,int [] popA) {
	     Stack<Integer> stack = new Stack<Integer>();
	     int j = 0;
	     for(int i=0;i<pushA.length;++i) {
	    	 stack.push(pushA[i]);
	    	 while(!stack.isEmpty() && popA[j] == stack.peek()) {
	    		 ++j;
	    		 stack.pop();
	    	 }
	     }
	     return stack.isEmpty();	     
    }
}
